<?php $this->_extends('_layouts/default_layout'); ?>

<?php $this->_block('contents'); ?>

<h3>添加电话号码</h3>
<div class="text">
<form action="<?php echo url('telephonebook/add'); ?>" method="post" name="mainform" >
        <table cellpadding="0" id="ParamConf" name="ParamConf" cellspacing="0" width="100%">
        <tbody class="">
                <tr class="tth">
                <td width="20%">用户姓名</td>
                <td width="40%">电话号码</td>
                <td width="20%">号码排序</td>
        </tr>
                <tr>
                <td><input class="input" type="text" value="" name="tel_name[]" id="1011" size="10" /></td>
                <td><input class="input" type="text" value="" name="tel_phone[]" id="1012" size="30" /></td>
                <td><input class="input" type="text" value="" name="tel_sequence[]" id="1013" size="5" /></td>
        </tr> 
                <tr>
                <td><input class="input" type="text" value="" name="tel_name[]" id="1014" size="10" /></td>
                <td><input class="input" type="text" value="" name="tel_phone[]" id="1015" size="30" /></td>
                <td><input class="input" type="text" value="" name="tel_sequence[]" id="1016" size="5" /></td>
        </tr> 
                <tr>
                <td><input class="input" type="text" value="" name="tel_name[]" id="1017" size="10" /></td>
                <td><input class="input" type="text" value="" name="tel_phone[]" id="1018" size="30" /></td>
                <td><input class="input" type="text" value="" name="tel_sequence[]" id="1019" size="5" /></td>
        </tr> 
                <tr>
                <td><input class="input" type="text" value="" name="tel_name[]" id="1020" size="10" /></td>
                <td><input class="input" type="text" value="" name="tel_phone[]" id="1021" size="30" /></td>
                <td><input class="input" type="text" value="" name="tel_sequence[]" id="1022" size="5" /></td>
        </tr> 
                <tr>
                <td><input class="input" type="text" value="" name="tel_name[]" id="1023" size="10" /></td>
                <td><input class="input" type="text" value="" name="tel_phone[]" id="1024" size="30" /></td>
                <td><input class="input" type="text" value="" name="tel_sequence[]" id="1025" size="5" /></td>
        </tr> 

        </tbody>
        </table>

        <table cellpadding="0" id="btn" name="btn" cellspacing="0" width="100%">
        <tr>
                <td class="tbutton" colspan="6"><input type="submit" value="提交" class="btn" name="sby" onclick="return (CheckIsNull())"></td>
        </tr>
        </table>
</form>
</div>


<script type="text/javascript"> 
var index; 
index = 0; 

//新增一条参数信息 
function addParamConf(){ 
    s1 = "<tr><td><input name='tel_name[]' class='input' id='1011"+index+"'type='text'  size='10'  value=''/></td>  <td><input name='tel_phone[]' class='input' id='1011"+index+1+"'type='text'  size='30'  value=''/></td>	  <td><input name='tel_sequence[]' class='input' id='1011"+index+2+"'type='text'  size='5'  value=''/></td></tr>"; 
    //s4 = "<a href=javascript:deleteParamConf('"+index+"')>删除</a>"; 
    arow = ParamConf.insertRow(); 
    arow.id="ParamConf"+index; 
    c1 = arow.insertCell(); 
    c1.align="left"; 
    c1.className='td_rb'; 
    c1.innerHTML=s1; 

    index = index*3+1; 
    //window_resize(); 
    //initWindow(true); 
} 
//删除行 
function deleteParamConf(index){ 
    var nameinput = document.getElementById("1011"+index);
    if(nameinput.value != "")
    {
        if(window.confirm('确定要删除这条记录吗?')){ 
            ParamConf.deleteRow(document.getElementById("ParamConf"+index).rowIndex); 

            this.index = this.index - 1*3; 
        } 
    }
    else
    {
        ParamConf.deleteRow(document.getElementById("ParamConf"+index).rowIndex); 

        this.index = this.index - 1; 
    }
} 
function CheckIsNull()
{ 
    var name0_input = document.getElementById("1011");
    if(name0_input!= null && name0_input.value != "")
    {
        return true;
    }
    var name1_input = document.getElementById("1012");
    if(name1_input!= null && name1_input.value != "")
    {
        return true;
    }
    for(i=0; i<index; i++)
    {
        var name_input = document.getElementById("1011"+i);
        if(name_input!= null && name_input.value != "")
        {
            return true;
        }
    }
    alert("请输入部门名称");
    return false;
}
function GetLastIndex()
{
    return this.index;
}
</script> 

<?php $this->_endblock(); ?>
